<template>
  <div class="flex flex-col h-full">
    <a-card class="mt-2 flex-1">
      <BaseTable :loading="loading" column-code="000410" :data-source="tableData" fill>
        <template #bodyCell="{ column, index, record }">
          <template v-if="column.dataIndex === 'NO'">
            {{ index + 1 }}
          </template>
          <template v-if="column.dataIndex === 'isReportShowFlag'">
            <a-switch v-model:checked="record.isReportShowFlag" :un-checked-value="0" :checked-value="1" @change="onSwitch(record)" />
          </template>

          <template v-if="column.dataIndex === 'outorder'">
            <EditCell>
              <BaseInput v-model:value="record.outorder" v-input:int placeholder="请输入" @blur="onSwitch(record)" @keydown.enter="onSwitch(record)" />
            </EditCell>
          </template>
        </template>
      </BaseTable>
    </a-card>
  </div>
</template>

<script setup>
// import { ref } from 'vue'
import { message } from 'ant-design-vue'
import { post } from '@/utils/request'
// import { message } from 'ant-design-vue'

const { loading, tableData, getData } = useTable({
  url: '/operation/opex/getXmlbbList',
  immediate: true
})
const onSwitch = async (record) => {
  const { code, msg } = await post('/operation/opex/doSaveIsReportShowFlag', {
    ...record,
    outorder: Number(record.outorder)
  })
  if (code !== 0) return message.error(msg)
  message.success(msg)
  getData()
}
</script>

<style lang="less" scoped></style>
